package com.zwan.oam_rtc.utils.messages;

import java.nio.ByteBuffer;

import com.zwan.oam_rtc.utils.wintcp.ByteTransfer;



public class CallingMessage extends AbstractStruct {
    
//    DWORD dwFunctionType    1_webcall
//    DWORD dwSubType 0-  �˳���¼
//    1-  ����
//    2-  ͨ����
//    3-  �����У��ȴ�����Ӧ��
//    Char  String1[30]    Callingnumber (�û�����)
//    DWORD userid    Userid��Ӧ�� tb_userinfo.userid
//    char  strtmp2[40]    Username ��Ӧ�� tb_userinfo. Loginname
//    Char  String3[30]    Callflowid (������Ŵ���������tb_callinfo.callflowid)
//    DWORD dwtmp3    �ݲ�ʹ��

    private int dwFunction = 1;
    private int dwSubType = 0;
    private byte[] calling = new byte[30];
    private int userid;
    private byte[] loginName = new byte[40];
    private byte[] callflowid = new byte[30];
    private int dwtmp3;
    private static int LENGTH = 116;
    
    @Override
    public void writeToBuffer(ByteBuffer bf) {
        bf.putInt(dwFunction);
        bf.putInt(dwSubType);
        bf.put(calling);
        bf.putInt(userid);
        bf.put(loginName);
        bf.put(callflowid);
        bf.putInt(dwtmp3);
    }

    @Override
    public void readFromBuffer(ByteBuffer bf) {
        dwFunction = bf.getInt();
        dwSubType = bf.getInt();
        bf.get(calling);
        userid = bf.getInt();
        bf.get(loginName);
        bf.get(callflowid);
        dwtmp3 = bf.getInt();
    }

    public int getUserid() {
        return userid;
    }

    public void setUserid(int userid) {
        this.userid = userid;
    }
    
    @Override
    public int getLength() {
        return LENGTH;
    }

    public int getDwFunction() {
        return dwFunction;
    }

    public void setDwFunction(int dwFunction) {
        this.dwFunction = dwFunction;
    }

    public int getDwSubType() {
        return dwSubType;
    }

    public void setDwSubType(int dwSubType) {
        this.dwSubType = dwSubType;
    }

    public String getCalling() {
        return ByteTransfer.getString(calling);
    }

    public void setCalling(String calling) {
        ByteTransfer.str2Byte(calling, this.calling);
    }

    public String getUserName() {
        return ByteTransfer.getString(loginName);
    }

    public void setUserName(byte[] strtmp2) {
        System.arraycopy(strtmp2, 0, this.loginName, 0, Math.min(strtmp2.length, this.loginName.length));
    }

    public int getDwtmp3() {
        return dwtmp3;
    }

    public void setDwtmp3(int dwtmp3) {
        this.dwtmp3 = dwtmp3;
    }

    public String getCallflowid() {
        return ByteTransfer.getString(callflowid);
    }

    public void setCallflowid(byte[] callflowid) {
        System.arraycopy(callflowid, 0, this.callflowid, 0, Math.min(callflowid.length, this.callflowid.length));
    }
}
